
public abstract class LoginMech {
	
	/**
	 * Runs a check with the database to see if a user successfully logged in.
	 * @param username Username of the user.
	 * @param password Password of the user
	 * @return the String that designates whether it is locked or not.
	 */
	public static String checkLogin(String username, String password){
		
		if(UserDatabase.searchUser(username, UserDatabase.USERNAME_SEARCH).size() == 0){
			return "invalid";
		}
		else{
			User user = UserDatabase.searchUser(username, 
					UserDatabase.USERNAME_SEARCH).get(0);
		
			if (user.isLocked()) {
				return "locked";
			}
			else if (user.getPassword().equals(password)){
				return "success";
			}
			else {
				//Only increments lockout counter if there is a valid account to lock
				user.lockCounter++;
				if (user.lockCounter >= 3) user.locked = true;
				return "invalid";
			}
		}
	}
}
